<template>
  <section class="page">
    <!-- 标题 -->
    <div class="title">
      <div>东莞市站成鞋业有限公司{{ this.propsForm.fullnmT || "" }}</div>
      <div>订&emsp;购&emsp;单</div>
    </div>
    <!-- 表单字段 -->
    <div class="form" style="position: relative">
      <div style="position: absolute; top: -1.4em">季节：{{ this.propsForm.season || "" }}</div>
      <div class="form-row">
        <div>厂&emsp;商：{{ this.propsForm.fullnmTC || "" }}</div>
        <div>传真：{{ this.propsForm.vrFax || "" }}</div>
        <div>采购单号：{{ this.propsForm.orderNo || "" }}</div>
      </div>
      <div class="form-row">
        <div class="form-long-item">负责人：{{ this.propsForm.link || "" }}</div>
        <div>订购日期：{{ this.propsForm.ordDate || "" }}</div>
      </div>
      <div class="form-row">
        <div>电&emsp;话：{{ this.propsForm.vrTel || "" }}</div>
        <div>客户：{{ this.propsForm.client || "" }}</div>
        <div>交货地点：{{ this.propsForm.place || "" }}</div>
      </div>
    </div>
    <!-- 表格 -->
    <table style="width: 100%" border="1" cellspacing="0">
      <thead>
        <tr class="text-center bg-color">
          <th class="table-col-short">序</th>
          <th class="table-col">材料编码</th>
          <th>材料名称</th>
          <th class="table-col-short">单位</th>
          <th class="table-col">数量</th>
          <th class="table-col">单价</th>
          <th class="table-col">交期</th>
          <th class="table-col">材料备注</th>
        </tr>
      </thead>
      <tbody>
        <template v-for="(item, index) in this.propsForm.detailList || []">
          <tr :key="index + 'only'">
            <td class="text-center">
              {{ item.orderSeq }}
            </td>
            <td>
              {{ item.itemNo }}
            </td>
            <td>
              {{ item.itemName }}
            </td>
            <td class="text-center">
              {{ item.unit }}
            </td>
            <td class="text-center">
              {{ item.ordQty }}
            </td>
            <td class="text-center">
              {{ item.price }}
            </td>
            <td class="text-center">
              {{ item.planDate.substring(0, 10) }}
            </td>
            <td>
              {{ item.remark }}
            </td>
          </tr>
        </template>
        <tr>
          <td colspan="3" style="border-right: none"></td>
          <td colspan="1" style="border-right: none; border-left: none; text-align: right">共计:</td>
          <td colspan="1" style="border-left: none; border-right: none; text-align: center">{{ total }}</td>
          <td colspan="3" style="border-left: none"></td>
        </tr>
      </tbody>
    </table>
    <div class="base-stamp" style="margin-top: 3em">
      <table cellspacing="0" cellpadding="0" border="0" class="el-table__header table-flow">
        <thead class="has-gutter">
          <tr class="text-left">
            <th><div class="examine-cell">签核角色</div></th>
            <th><div class="examine-cell">审核人员</div></th>
            <th><div class="examine-cell">审核状况</div></th>
            <th><div class="examine-cell">审核意见</div></th>
            <th><div class="examine-cell">审核时间</div></th>
          </tr>
        </thead>
        <tbody>
          <template>
            <tr class="text-left" v-for="(item, index) in propsForm.qhChkmgrdList || []" :key="index">
              <td>
                <div>{{ item.flowDesc }}</div>
              </td>
              <td>
                <div>{{ item.toUserCname }}</div>
              </td>
              <td>
                <div>{{ item.chkStatusName }}</div>
              </td>
              <td>
                <div>{{ item.chkOk }}</div>
              </td>
              <td>
                <div>{{ item.chkDate }}</div>
              </td>
            </tr>
          </template>
        </tbody>
      </table>
    </div>
  </section>
</template>

<script>
module.exports = {
  props: {
    propsForm: {
      type: Object,
      required: true,
    },
  },
  data() {
    return {
      sessionStorageData: JSON.parse(sessionStorage.parameterData),
      applicationForm: {
        detailList: [],
      },
    };
  },
  computed: {
    total() {
      const list = this.propsForm.detailList;
      const total = list.reduce((pre, cur) => {
        pre += +cur.ordQty;
        return pre;
      }, 0);
      return +total.toFixed(2);
    },
  },
  mounted() {},
};
</script>

<style scoped>
.page {
  margin: 0 auto;
  width: 29cm;
  padding: 2em;
  font-size: 14px;
}
section {
  --border: 1px solid #000;
  --bg-color: #b3ffb3;
}
.title {
  font-size: 20px;
  line-height: 1.4;
  text-align: center;
  margin-bottom: 0.5em;
}

.form {
  margin-bottom: 0.5em;
}
.form-row {
  display: flex;
  justify-content: space-between;
  line-height: 1.8;
  text-align: left;
}
.form-row > div {
  flex-basis: 33%;
}
.form-long-item {
  flex-basis: 66%;
}

table {
  font-size: 14px;
}
table th,
td {
  padding: 4px;
}
.table-col-short {
  width: 3em;
}
.table-col {
  width: 6em;
}

/* commom */
.text-center {
  text-align: center;
}
.bg-color {
  background-color: var(--bg-color);
}
</style>
